﻿# Find a building type with highest priority + order pair and try to construct it
aroai_choose_building_type_to_construct = {

    # Set local variable that equals to highest priority, note that highest means lower number
    aroai_perform_for_every_building_type = {
        effect = 6 # aroai_compare_building_priority_with_current_highest
    }

    # If variable wasn't set, then there is nothing to construct
    if = {
        limit = {
            NOT = {
                has_local_variable = aroai_highest_building_priority
            }
        }
        aroai_clear_country_iteration_variables = yes
    }

    # Otherwise choose a building type with highest priority to construct
    else = {

        # If there are no building types with priority higher than 6 and we haven't tried special buildings yet, do it
        if = {
            limit = {
                local_var:aroai_highest_building_priority = 6
                NOT = {
                    has_variable = aroai_tried_special_buildings
                }
            }
            aroai_construct_special_buildings = yes
        }

        # Otherwise proceed with general buildings
        else = {

            # Create local variable list of building types with highest priority in form of $id$.$order$ array variable
            aroai_perform_for_every_building_type = {
                effect = 7 # aroai_add_to_list_of_buildings_with_highest_priority
            }

            # Find a building type with highest order in this list, ties are resolved by random
            random_in_local_list = {
                variable = aroai_buildings_with_highest_priority
                limit = {
                    NOT = {
                        any_in_local_list = {
                            variable = aroai_buildings_with_highest_priority
                            aroai_order_of_current_element < prev.aroai_order_of_current_element
                        }
                    }
                }

                # This building type would be the one we are going to construct
                aroai_perform_for_every_building_type = {
                    effect = 8 # aroai_choose_states_to_start_construction
                }
            }

            # Garbage collection
            clear_local_variable_list = aroai_buildings_with_highest_priority
        }
        
        # Garbage collection
        remove_local_variable = aroai_highest_building_priority
        
        # If construction of chosen building type failed to start for whatever reason, choose another one
        if = {
            limit = {
                NOT = {
                    has_local_variable = aroai_started_building_construction
                }
            }
            aroai_choose_building_type_to_construct = yes
        }

        # Otherwise just schedule future constructions if there are building type with priorities left
        else = {

            # Clear successful construction flag
            remove_local_variable = aroai_started_building_construction

            # If we have some days left in the iteration, book an event tomorrow
            if = {
                limit = {
                    aroai_day_of_ongoing_iteration < aroai_half_of_days_in_iteration_rounded_down
                }
                trigger_event = {
                    id = aroai_construction_events.1
                    days = 1
                }
            }
            
            # Otherwise exit this event chain
            else = {

                # In rare cases even after constructing a dozen of building types there are still both free construction
                # points and some building types that were not yet processed, so we cycle through them all in one day.
                if = {
                    limit = {
                        aroai_has_free_construction_points = yes
                    }
                    aroai_choose_building_type_to_construct = yes
                }

                # But usually we just clear variables and that's it
                else = {
                    aroai_clear_country_iteration_variables = yes
                }
            }
        }
    }
}

# Set local variable that equals to highest priority, note that highest means lower number
aroai_compare_building_priority_with_current_highest = {
    if = {
        limit = {
            has_variable = aroai_building_type_$id$_collected_data
            aroai_building_type_$id$_collected_data_1 > 0
            OR = {
                NOT = {
                    has_local_variable = aroai_highest_building_priority
                }
                local_var:aroai_highest_building_priority > aroai_building_type_$id$_collected_data_1
            }
        }
        set_local_variable = {
            name = aroai_highest_building_priority
            value = aroai_building_type_$id$_collected_data_1
        }
    }
}

# Create local variable list of building types with highest priority in form of $id$.$order$ array variable
aroai_add_to_list_of_buildings_with_highest_priority = {
    if = {
        limit = {
            has_variable = aroai_building_type_$id$_collected_data
            aroai_building_type_$id$_collected_data_1 > 0
            local_var:aroai_highest_building_priority = aroai_building_type_$id$_collected_data_1
        }
        add_to_local_variable_list = {
            name = aroai_buildings_with_highest_priority
            target = $id$.$order$
        }
    }
}

# We know what to construct now, but where?
aroai_choose_states_to_start_construction = {

    # Before we start, make an additional counter check cause something may have changed
    if = {
        limit = {
            aroai_check_if_counter_is_within_limit = {
                id = $id$
                counter = $counter$
                limit = $limit$
            }
        }

        # Set variable in every state with occupancy of building of current type
        every_scope_building = {
            limit = {
                is_building_type = $key$
                OR = {
                    level > 0
                    is_under_construction = yes
                }
            }
            state = {
                set_variable = {
                    name = aroai_building_type_occupied_levels
                    value = {
                        value = prev.level
                        multiply = prev.occupancy
                        min = 0.1
                    }
                }
            }
        }

        # If variable was not set, then there's no such building or it has no occupancy, so set variable as 0
        every_scope_state = {
            limit = {
                NOT = {
                    has_variable = aroai_building_type_occupied_levels
                }
            }
            set_variable = {
                name = aroai_building_type_occupied_levels
                value = 0
            }
        }

        # States from allocation lists are filtered by aroai_requirements_for_construction_in_state trigger, and in case
        # of branching being true all the states are also sorted by conditions like being incorporated or having enough
        # infrastructure. Then lists of filtered and states are passed to aroai_start_building_construction one by one. 
        aroai_filter_and_sort_states_from_allocation_lists = {
            key = $key$
            id = $id$
            class = $class$
            counter = $counter$
            branching = $branching$
            allocate = $allocate$
            workforce = $workforce$
            crucial = $crucial$
            limit = $limit$
            scaling = $scaling$
        }

        # Garbage collection
        every_scope_state = {
            remove_variable = aroai_building_type_occupied_levels
        }
    }

    # Set building type priority to 0 so we don't process it anymore in this iteration
    change_variable = {
        name = aroai_building_type_$id$_collected_data
        subtract = {
            value = aroai_building_type_$id$_collected_data_1
            divide = 100
        }
    }
}

# Branching algorithm used in aroai_filter_and_sort_states_from_allocation_lists. Splits input allocation list into
# a bunch of branch lists sorted by conditions below. Note that in the current implementation, if you have for example
# two different allocation lists, the result will be A1B1 A2B1 - A1B2 A2B2 - A1B3 A2B3 - A1B4 A2B4. Branch conditions
# are considered more important than allocation conditions, so states from all allocation lists will be reshuffled so
# that all the states that fit first branch conditions will be grouped, then all the states from second condition, etc.
# But inside of branch group the allocation order is preserved, all A1B1 states will be processed strictly before A2B1.
aroai_perform_branching_of_allocation_list = {
    every_in_list = {
        variable = aroai_building_type_$id$_allocation_$index_1$
        limit = {
            aroai_requirements_for_construction_in_state = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
            }
        }
        if = {
            limit = {
                is_incorporated = yes
                aroai_has_enough_infrastructure = yes
                aroai_has_enough_workforce = yes
            }
            root = {
                add_to_variable_list = {
                    name = aroai_building_type_$id$_branch_$index_1$
                    target = prev
                }
            }
        }
        else_if = {
            limit = {
                aroai_has_enough_infrastructure = yes
                aroai_has_enough_workforce = yes
            }
            root = {
                add_to_variable_list = {
                    name = aroai_building_type_$id$_branch_$index_2$
                    target = prev
                }
            }
        }
        else_if = {
            limit = {
                OR = {
                    AND = {
                        is_incorporated = yes
                        aroai_has_enough_workforce = yes
                    }
                    aroai_has_enough_infrastructure = yes
                }
            }
            root = {
                add_to_variable_list = {
                    name = aroai_building_type_$id$_branch_$index_3$
                    target = prev
                }
            }
        }
        else = {
            root = {
                add_to_variable_list = {
                    name = aroai_building_type_$id$_branch_$index_4$
                    target = prev
                }
            }
        }
    }
}

# Takes list of states as input, chooses in which one of them to start construction and queues 1 level of building
aroai_start_building_construction = {

    # If we got there, then construction is successful (for aroai_choose_building_type_to_construct)
    set_local_variable = {
        name = aroai_started_building_construction
        value = yes
        days = aroai_days_to_keep_short_variables
    }

    # Cycle through states in the list while we can
    while = {
        limit = {
            aroai_has_variable_list = {
                name = $states$
            }
            aroai_check_if_counter_is_within_limit = {
                id = $id$
                counter = $counter$
                limit = $limit$
            }
        }

        # Take a random list that fits conditions below
        random_in_list = {
            variable = $states$
            limit = {
                save_temporary_scope_as = aroai_current_state
                root = {

                    # If economy of scaling applies to this building type
                    trigger_if = {
                        limit = {
                            $scaling$ = 1
                        }
                        OR = {

                            # Either this is a state with one of the highest levels of this building type in a country
                            any_scope_state = {
                                var:aroai_building_type_occupied_levels > aroai_current_aroai_building_type_occupied_levels
                                count < aroai_simultaneously_developed
                            }

                            # Or there are no states with higher level in this list
                            NOT = {
                                any_in_list = {
                                    variable = $states$
                                    var:aroai_building_type_occupied_levels > aroai_current_aroai_building_type_occupied_levels
                                }
                            }
                        }
                    }

                    # If economy of scaling does not apply
                    trigger_else = {

                        # Take a state with the lowest level of this building type in the list
                        NOT = {
                            any_in_list = {
                                variable = $states$
                                var:aroai_building_type_occupied_levels < aroai_current_aroai_building_type_occupied_levels
                            }
                        }
                    }

                    # Additional conditions to construct new buildings
                    OR = {

                        # If there is already some levels of the building in the state, we don't care
                        aroai_current_aroai_building_type_occupied_levels > 0

                        # For constructing buildings from scratch
                        OR = {

                            # Either this is a state with one of the highest available workforce in the entire country
                            any_scope_state = {
                                var:aroai_building_type_occupied_levels = 0
                                aroai_available_workforce > scope:aroai_current_state.aroai_available_workforce
                                count < aroai_states_for_new_buildings
                            }

                            # Or there are no states with higher available workforce in this list
                            NOT = {
                                any_in_list = {
                                    variable = $states$
                                    var:aroai_building_type_occupied_levels = 0
                                    aroai_available_workforce > scope:aroai_current_state.aroai_available_workforce
                                }
                            }
                        }
                    }
                }
            }

            # We'll need it here and there
            save_scope_as = aroai_current_state

            # We check if we managed to start construction by comparing number of queued levels in the queue before and
            # after using start_building_construction. Note about $id$ = 5 aka Port: while other buildings are allowed
            # to get constructed many times in the same state, ports are not due to their allocation conditions being
            # pretty complex (e.g. you don't need more than one port for just market access) but it would be expensive
            # to track properly and it's not a big deal, so we always build one port per state and don't check stuff
            # like queued levels because of this, we just always assume the construction is successful and move on.
            if = {
                limit = {
                    NOT = {
                        $id$ = 5 # Port
                    }
                }
                set_local_variable = {
                    name = aroai_construction_queue_num_queued_levels
                    value = root.construction_queue_num_queued_levels
                }
            }

            # This little line is everything we want, but many thousands of other lines are required to use it properly
            start_building_construction = $key$

            # Set cooldown for government buildings
            if = {
                limit = {
                    OR = {
                        $id$ = 1 # Government administration
                        $id$ = 2 # University
                        $id$ = 3 # Construction sector
                        $id$ = 5 # Port
                        $id$ = 6 # Barracks
                        $id$ = 7 # Naval base
                    }
                }
                root = {
                    aroai_renew_variable = {
                        name = aroai_$key$_cooldown
                        days = aroai_days_in_building_cooldown
                    }
                }
            }
            
            # We can't check how many levels of a building are queued in a state as well as how many points are left
            # before construction will end, so we roughly track it using state scope variable list of array variables.
            # This is important for workforce (hiring for new buildings) and railways. Progress is added in weekly loop.
            if = {
                limit = {
                    OR = {
                        $id$ = 5 # Port
                        local_var:aroai_construction_queue_num_queued_levels < root.construction_queue_num_queued_levels
                    }
                }
                
                # ---------------------------------------------------------------------------------------------------
                # aroai_ongoing_construction is an array variable, and aroai_ongoing_constructions is a list of them.
                # Search for "Cell distribution of aroai_ongoing_construction" in aroai_construction_values.txt
                # ---------------------------------------------------------------------------------------------------

                # Set up a new record of ongoing construction that we'll add into the list
                set_local_variable = {
                    name = aroai_ongoing_construction
                    value = {

                        # Cell 1
                        value = $id$
                        max = 9999
                        divide = 100

                        # Cell 2
                        add = {

                            # Construction sector and military buildings
                            if = {
                                limit = {
                                    OR = {
                                        $id$ = 3 # Construction sector
                                        $class$ = 3 # Military
                                    }
                                }
                                value = construction_cost_very_low
                            }
                            
                            # Agriculture and "light" resources
                            else_if = {
                                limit = {
                                    OR = {
                                        AND = {
                                            $class$ = 4 # Resources
                                            $id$ <= 11 # "Light" resources
                                        }
                                        $class$ = 5 # Agriculture
                                    }
                                } 
                                value = construction_cost_low
                            }

                            # Government, port, "heavy" resources
                            # Commented out due to medium being fallback
                            # else_if = {
                                # limit = {
                                    # OR = {
                                        # $class$ = 1 # Government
                                        # $id$ = 5 # Port
                                        # AND = {
                                        #     $class$ = 4 # Resources
                                        #     $id$ >= 12 # "Medium" resources
                                        # }
                                    # }
                                # }
                                # value = construction_cost_medium
                            # }

                            # First check if building is "very_high" cause there's no separate class with them
                            else_if = {
                                limit = {
                                    $id$ >= 44 # Range of building types with very high cost
                                    $id$ <= 48
                                }
                                value = construction_cost_very_high
                            }

                            # Then check if it's "high" building
                            else_if = {
                                limit = {
                                    OR = {
                                        $id$ = 4 # Railway
                                        $class$ = 6 # Industry
                                    }
                                }
                                value = construction_cost_high
                            }

                            # Fallback
                            else = {
                                value = construction_cost_medium
                            }

                            # Formatting
                            round = yes
                            max = 9999
                            multiply = 100
                        }

                        # Cell 3
                        add = 1000000
                    }
                }

                # If there's already such a element in the list with everything except count being the same, set local
                # variable equal to it and delete the element, so we group multiple levels in one element of the list.
                if = {
                    limit = {
                        aroai_has_variable_list = {
                            name = aroai_ongoing_constructions
                        }
                    }
                    random_in_list = {
                        variable = aroai_ongoing_constructions
                        limit = {
                            local_var:aroai_ongoing_construction = aroai_current_ongoing_constructions_element_without_count
                        }
                        set_local_variable = {
                            name = aroai_ongoing_construction
                            value = this
                        }
                        scope:aroai_current_state = {
                            remove_list_variable = {
                                name = aroai_ongoing_constructions
                                target = prev
                            }
                        }
                    }
                }

                # Cell 4
                change_local_variable = {
                    name = aroai_ongoing_construction
                    add = 10000000
                }

                # Add to the list
                add_to_variable_list = {
                    name = aroai_ongoing_constructions
                    target = local_var:aroai_ongoing_construction
                }

                # Garbage collection
                remove_local_variable = aroai_ongoing_construction
            }
            
            # Check if construction actually started
            if = {
                limit = {
                    NOT = {
                        $id$ = 5 # Port
                    }
                }

                # If number of queued levels changed, then probably yes
                if = {
                    limit = {
                        local_var:aroai_construction_queue_num_queued_levels < root.construction_queue_num_queued_levels
                    }

                    # Add a level to state scope variable to help in further decision making on where to construct
                    change_variable = {
                        name = aroai_building_type_occupied_levels
                        add = 1
                    }

                    # Add a level to building type counter
                    root = {
                        aroai_add_to_building_type_counter = {
                            counter = $counter$
                            value = 1
                        }
                    }

                    # Tracking of free arable land for agriculture buildings
                    if = {
                        limit = {
                            aroai_is_agriculture_building = {
                                class = $class$
                            }
                        }
                        if = {
                            limit = {
                                NOT = {
                                    has_variable = aroai_queued_agriculture_buildings
                                }
                            }
                            set_variable = {
                                name = aroai_queued_agriculture_buildings
                                value = 1
                            }
                        }
                        else = {
                            change_variable = {
                                name = aroai_queued_agriculture_buildings
                                add = 1
                            }
                        }
                    }

                    # Check if state is no longer suitable for construction
                    if = {
                        limit = {
                            OR = {

                                # Not enough infrastructure
                                AND = {
                                    $id$ = 4
                                    aroai_infrastructure_balance_value_with_ongoing_constructions >= 0
                                }

                                # Can't queue more levels of the building
                                NOT = {
                                    any_scope_building = {
                                        is_building_type = $key$
                                        can_queue_building_levels = 1
                                    }
                                }

                                # Workforce restrictions
                                NOR = {
                                    $workforce$ = 0
                                    root.aroai_building_type_$id$_collected_data_2 <= $crucial$
                                    aroai_available_workforce >= aroai_required_workforce
                                }

                                # No arable land for agriculture buildings
                                NOR = {
                                    NOT = {
                                        aroai_is_agriculture_building = {
                                            class = $class$
                                        }
                                    }
                                    AND = {
                                        free_arable_land > 0
                                        OR = {
                                            NOT = {
                                                has_variable = aroai_queued_agriculture_buildings
                                            }
                                            var:aroai_queued_agriculture_buildings < free_arable_land
                                        }
                                    }
                                }
                            }
                        }

                        # If any of above is true, remove the state from the list
                        root = {
                            remove_list_variable = {
                                name = $states$
                                target = prev
                            }
                        }
                    }
                }

                # If number of queued levels is the same, construction probably failed, remove the state from the list
                else = {
                    root = {
                        remove_list_variable = {
                            name = $states$
                            target = prev
                        }
                    }
                }

                # Garbage collection
                remove_local_variable = aroai_construction_queue_num_queued_levels
            }

            # For ports we always assume construction is successful so we add a level to the counter, but we still
            # remove the state from the list because we don't want to build more than one port at time in a state.
            else = {
                root = {
                    aroai_add_to_building_type_counter = {
                        counter = $counter$
                        value = 1
                    }
                    remove_list_variable = {
                        name = $states$
                        target = prev
                    }
                }
            }

            # Garbage collection
            clear_saved_scope = aroai_current_state
        }
    }
}

# Generated with modding tool, don't edit it manually
aroai_filter_and_sort_states_from_allocation_lists = {
    if = {
        limit = {
            $branching$ = 0
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_1
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_1
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_1
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_1
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_2
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_2
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_2
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_2
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_3
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_3
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_3
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_3
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_4
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_4
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_4
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_4
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_5
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_5
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_5
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_5
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_6
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_6
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_6
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_6
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_7
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_7
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_7
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_7
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_8
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_8
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_8
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_8
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_9
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_9
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_9
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_9
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
        if = {
            limit = {
                has_variable_list = aroai_building_type_$id$_allocation_10
                aroai_check_if_counter_is_within_limit = {
                    id = $id$
                    counter = $counter$
                    limit = $limit$
                }
            }
            every_in_list = {
                variable = aroai_building_type_$id$_allocation_10
                limit = {
                    NOT = {
                        aroai_requirements_for_construction_in_state = {
                            id = $id$
                            class = $class$
                            workforce = $workforce$
                            crucial = $crucial$
                        }
                    }
                }
                root = {
                    remove_list_variable = {
                        name = aroai_building_type_$id$_allocation_10
                        target = prev
                    }
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_allocation_10
                }
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_allocation_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
        }
    }
    else = {
        if = {
            limit = {
                $allocate$ = 1
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 2
                index_3 = 3
                index_4 = 4
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
        }
        else_if = {
            limit = {
                $allocate$ = 2
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 3
                index_3 = 5
                index_4 = 7
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 4
                index_3 = 6
                index_4 = 8
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
        }
        else_if = {
            limit = {
                $allocate$ = 3
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 4
                index_3 = 7
                index_4 = 10
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 5
                index_3 = 8
                index_4 = 11
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 6
                index_3 = 9
                index_4 = 12
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
        }
        else_if = {
            limit = {
                $allocate$ = 4
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 5
                index_3 = 9
                index_4 = 13
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 6
                index_3 = 10
                index_4 = 14
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 7
                index_3 = 11
                index_4 = 15
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 8
                index_3 = 12
                index_4 = 16
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
        }
        else_if = {
            limit = {
                $allocate$ = 5
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 6
                index_3 = 11
                index_4 = 16
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 7
                index_3 = 12
                index_4 = 17
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 8
                index_3 = 13
                index_4 = 18
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 9
                index_3 = 14
                index_4 = 19
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 10
                index_3 = 15
                index_4 = 20
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
        }
        else_if = {
            limit = {
                $allocate$ = 6
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 7
                index_3 = 13
                index_4 = 19
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 8
                index_3 = 14
                index_4 = 20
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 9
                index_3 = 15
                index_4 = 21
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 10
                index_3 = 16
                index_4 = 22
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 11
                index_3 = 17
                index_4 = 23
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 6
                index_2 = 12
                index_3 = 18
                index_4 = 24
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_21
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_21
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_22
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_22
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_23
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_23
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_24
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_24
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
            clear_variable_list = aroai_building_type_$id$_branch_21
            clear_variable_list = aroai_building_type_$id$_branch_22
            clear_variable_list = aroai_building_type_$id$_branch_23
            clear_variable_list = aroai_building_type_$id$_branch_24
        }
        else_if = {
            limit = {
                $allocate$ = 7
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 8
                index_3 = 15
                index_4 = 22
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 9
                index_3 = 16
                index_4 = 23
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 10
                index_3 = 17
                index_4 = 24
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 11
                index_3 = 18
                index_4 = 25
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 12
                index_3 = 19
                index_4 = 26
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 6
                index_2 = 13
                index_3 = 20
                index_4 = 27
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 7
                index_2 = 14
                index_3 = 21
                index_4 = 28
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_21
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_21
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_22
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_22
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_23
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_23
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_24
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_24
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_25
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_25
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_26
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_26
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_27
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_27
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_28
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_28
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
            clear_variable_list = aroai_building_type_$id$_branch_21
            clear_variable_list = aroai_building_type_$id$_branch_22
            clear_variable_list = aroai_building_type_$id$_branch_23
            clear_variable_list = aroai_building_type_$id$_branch_24
            clear_variable_list = aroai_building_type_$id$_branch_25
            clear_variable_list = aroai_building_type_$id$_branch_26
            clear_variable_list = aroai_building_type_$id$_branch_27
            clear_variable_list = aroai_building_type_$id$_branch_28
        }
        else_if = {
            limit = {
                $allocate$ = 8
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 9
                index_3 = 17
                index_4 = 25
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 10
                index_3 = 18
                index_4 = 26
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 11
                index_3 = 19
                index_4 = 27
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 12
                index_3 = 20
                index_4 = 28
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 13
                index_3 = 21
                index_4 = 29
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 6
                index_2 = 14
                index_3 = 22
                index_4 = 30
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 7
                index_2 = 15
                index_3 = 23
                index_4 = 31
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 8
                index_2 = 16
                index_3 = 24
                index_4 = 32
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_21
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_21
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_22
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_22
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_23
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_23
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_24
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_24
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_25
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_25
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_26
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_26
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_27
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_27
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_28
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_28
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_29
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_29
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_30
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_30
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_31
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_31
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_32
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_32
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
            clear_variable_list = aroai_building_type_$id$_branch_21
            clear_variable_list = aroai_building_type_$id$_branch_22
            clear_variable_list = aroai_building_type_$id$_branch_23
            clear_variable_list = aroai_building_type_$id$_branch_24
            clear_variable_list = aroai_building_type_$id$_branch_25
            clear_variable_list = aroai_building_type_$id$_branch_26
            clear_variable_list = aroai_building_type_$id$_branch_27
            clear_variable_list = aroai_building_type_$id$_branch_28
            clear_variable_list = aroai_building_type_$id$_branch_29
            clear_variable_list = aroai_building_type_$id$_branch_30
            clear_variable_list = aroai_building_type_$id$_branch_31
            clear_variable_list = aroai_building_type_$id$_branch_32
        }
        else_if = {
            limit = {
                $allocate$ = 9
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 10
                index_3 = 19
                index_4 = 28
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 11
                index_3 = 20
                index_4 = 29
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 12
                index_3 = 21
                index_4 = 30
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 13
                index_3 = 22
                index_4 = 31
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 14
                index_3 = 23
                index_4 = 32
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 6
                index_2 = 15
                index_3 = 24
                index_4 = 33
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 7
                index_2 = 16
                index_3 = 25
                index_4 = 34
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 8
                index_2 = 17
                index_3 = 26
                index_4 = 35
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 9
                index_2 = 18
                index_3 = 27
                index_4 = 36
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_21
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_21
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_22
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_22
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_23
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_23
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_24
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_24
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_25
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_25
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_26
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_26
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_27
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_27
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_28
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_28
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_29
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_29
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_30
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_30
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_31
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_31
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_32
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_32
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_33
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_33
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_34
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_34
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_35
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_35
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_36
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_36
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
            clear_variable_list = aroai_building_type_$id$_branch_21
            clear_variable_list = aroai_building_type_$id$_branch_22
            clear_variable_list = aroai_building_type_$id$_branch_23
            clear_variable_list = aroai_building_type_$id$_branch_24
            clear_variable_list = aroai_building_type_$id$_branch_25
            clear_variable_list = aroai_building_type_$id$_branch_26
            clear_variable_list = aroai_building_type_$id$_branch_27
            clear_variable_list = aroai_building_type_$id$_branch_28
            clear_variable_list = aroai_building_type_$id$_branch_29
            clear_variable_list = aroai_building_type_$id$_branch_30
            clear_variable_list = aroai_building_type_$id$_branch_31
            clear_variable_list = aroai_building_type_$id$_branch_32
            clear_variable_list = aroai_building_type_$id$_branch_33
            clear_variable_list = aroai_building_type_$id$_branch_34
            clear_variable_list = aroai_building_type_$id$_branch_35
            clear_variable_list = aroai_building_type_$id$_branch_36
        }
        else_if = {
            limit = {
                $allocate$ = 10
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 1
                index_2 = 11
                index_3 = 21
                index_4 = 31
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 2
                index_2 = 12
                index_3 = 22
                index_4 = 32
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 3
                index_2 = 13
                index_3 = 23
                index_4 = 33
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 4
                index_2 = 14
                index_3 = 24
                index_4 = 34
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 5
                index_2 = 15
                index_3 = 25
                index_4 = 35
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 6
                index_2 = 16
                index_3 = 26
                index_4 = 36
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 7
                index_2 = 17
                index_3 = 27
                index_4 = 37
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 8
                index_2 = 18
                index_3 = 28
                index_4 = 38
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 9
                index_2 = 19
                index_3 = 29
                index_4 = 39
            }
            aroai_perform_branching_of_allocation_list = {
                id = $id$
                class = $class$
                workforce = $workforce$
                crucial = $crucial$
                index_1 = 10
                index_2 = 20
                index_3 = 30
                index_4 = 40
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_1
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_1
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_2
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_2
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_3
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_3
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_4
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_4
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_5
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_5
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_6
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_6
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_7
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_7
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_8
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_8
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_9
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_9
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_10
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_10
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_11
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_11
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_12
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_12
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_13
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_13
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_14
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_14
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_15
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_15
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_16
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_16
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_17
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_17
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_18
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_18
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_19
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_19
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_20
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_20
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_21
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_21
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_22
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_22
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_23
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_23
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_24
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_24
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_25
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_25
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_26
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_26
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_27
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_27
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_28
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_28
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_29
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_29
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_30
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_30
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_31
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_31
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_32
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_32
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_33
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_33
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_34
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_34
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_35
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_35
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_36
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_36
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_37
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_37
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_38
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_38
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_39
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_39
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            if = {
                limit = {
                    has_variable_list = aroai_building_type_$id$_branch_40
                    aroai_check_if_counter_is_within_limit = {
                        id = $id$
                        counter = $counter$
                        limit = $limit$
                    }
                } 
                aroai_start_building_construction = {
                    states = aroai_building_type_$id$_branch_40
                    key = $key$
                    id = $id$
                    class = $class$
                    counter = $counter$
                    scaling = $scaling$
                    limit = $limit$
                    workforce = $workforce$
                    crucial = $crucial$
                }
            }
            clear_variable_list = aroai_building_type_$id$_branch_1
            clear_variable_list = aroai_building_type_$id$_branch_2
            clear_variable_list = aroai_building_type_$id$_branch_3
            clear_variable_list = aroai_building_type_$id$_branch_4
            clear_variable_list = aroai_building_type_$id$_branch_5
            clear_variable_list = aroai_building_type_$id$_branch_6
            clear_variable_list = aroai_building_type_$id$_branch_7
            clear_variable_list = aroai_building_type_$id$_branch_8
            clear_variable_list = aroai_building_type_$id$_branch_9
            clear_variable_list = aroai_building_type_$id$_branch_10
            clear_variable_list = aroai_building_type_$id$_branch_11
            clear_variable_list = aroai_building_type_$id$_branch_12
            clear_variable_list = aroai_building_type_$id$_branch_13
            clear_variable_list = aroai_building_type_$id$_branch_14
            clear_variable_list = aroai_building_type_$id$_branch_15
            clear_variable_list = aroai_building_type_$id$_branch_16
            clear_variable_list = aroai_building_type_$id$_branch_17
            clear_variable_list = aroai_building_type_$id$_branch_18
            clear_variable_list = aroai_building_type_$id$_branch_19
            clear_variable_list = aroai_building_type_$id$_branch_20
            clear_variable_list = aroai_building_type_$id$_branch_21
            clear_variable_list = aroai_building_type_$id$_branch_22
            clear_variable_list = aroai_building_type_$id$_branch_23
            clear_variable_list = aroai_building_type_$id$_branch_24
            clear_variable_list = aroai_building_type_$id$_branch_25
            clear_variable_list = aroai_building_type_$id$_branch_26
            clear_variable_list = aroai_building_type_$id$_branch_27
            clear_variable_list = aroai_building_type_$id$_branch_28
            clear_variable_list = aroai_building_type_$id$_branch_29
            clear_variable_list = aroai_building_type_$id$_branch_30
            clear_variable_list = aroai_building_type_$id$_branch_31
            clear_variable_list = aroai_building_type_$id$_branch_32
            clear_variable_list = aroai_building_type_$id$_branch_33
            clear_variable_list = aroai_building_type_$id$_branch_34
            clear_variable_list = aroai_building_type_$id$_branch_35
            clear_variable_list = aroai_building_type_$id$_branch_36
            clear_variable_list = aroai_building_type_$id$_branch_37
            clear_variable_list = aroai_building_type_$id$_branch_38
            clear_variable_list = aroai_building_type_$id$_branch_39
            clear_variable_list = aroai_building_type_$id$_branch_40
        }
    }
}